Skip to content

refactor: replace @astral/astral with puppeteer for browser tests#3740

Closed
bartlomieju wants to merge 7 commits into
mainfrom
refactor/replace-astral-with-puppeteer
Closed

refactor: replace @astral/astral with puppeteer for browser tests#3740
bartlomieju wants to merge 7 commits into
mainfrom
refactor/replace-astral-with-puppeteer

Conversation

@bartlomieju

Copy link
Copy Markdown
Contributor

Summary

Replaces @astral/astral with puppeteer@24 for browser tests. Astral is incompatible with @std/async@1.2.0 — it passes Infinity as maxAttempts to retry(), which the new version rejects. This breaks all browser tests when the lockfile resolves @std/async to 1.2.0 (which happens when any dependency pulls in @std/async@^1.1.0).

Approach

A thin PageWrapper class in test_utils.tsx provides an astral-compatible API on top of Puppeteer, so no test files need changes:

  • page.locator(sel).wait()page.waitForSelector(sel)
  • page.locator(sel).click()waitForSelector + click()
  • page.locator(sel).evaluate(fn)page.$eval(sel, fn)
  • page.addEventListener("console", ...)page.on("console", ...)
  • page.url (property) → page.url() (method)
  • page.waitForFunction(fn, { args })page.waitForFunction(fn, {}, ...args)

Files changed

  • deno.json — swap @astral/astral for puppeteer
  • packages/fresh/tests/test_utils.tsxPageWrapper + updated withBrowserApp/withBrowser
  • deno.lock — updated

Test plan

  • deno check passes on test_utils.tsx
  • CI browser tests pass (partials, islands, head, no_client_js, vite build/dev)

🤖 Generated with Claude Code

bartlomieju and others added 7 commits March 30, 2026 16:14
@astral/astral@0.5.5 is incompatible with @std/async@1.2.0 — it
passes Infinity as maxAttempts to retry(), which the new version
rejects. This breaks all browser tests when the lockfile resolves
@std/async to 1.2.0.

Replace with puppeteer@24, wrapped in a thin PageWrapper class that
provides an astral-compatible API (locator().wait(), locator().click(),
addEventListener, page.url property, waitForFunction with { args }).
Only test_utils.tsx changes — no test files need modifications.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- Replace @astral/astral import in www/utils/screenshot.ts with puppeteer
- Add generic type parameter to PageWrapper.locator<E>() to support
  .locator<HTMLPreElement>("pre") usage in test files

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Puppeteer requires a Chrome binary to be installed separately, unlike
astral which bundled its own. Add npx puppeteer browsers install step.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@astral/astral@0.5.5 is incompatible with @std/async@1.2.0 — it
passes Infinity as maxAttempts to retry(), which the new version
rejects. This breaks all browser tests when the lockfile resolves
@std/async to 1.2.0.

Replace with puppeteer@24, wrapped in a thin PageWrapper class that
provides an astral-compatible API. Convert all browser test files to
use integrationTest() wrapper (sanitizers disabled) since puppeteer
keeps internal WebSocket connections and timers alive.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@bartlomieju bartlomieju force-pushed the refactor/replace-astral-with-puppeteer branch from 7adb714 to 49c4522 Compare March 30, 2026 17:29
@bartlomieju

Copy link
Copy Markdown
Contributor Author

I'll just bump astral to 0.5.6 in another PR

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant